﻿using System;
using System.Collections.Generic;
using System.Text;

namespace JelleDruyts.Mollom.Client
{
    /// <summary>
    /// Provides data for an event indicating that a retryable operation failed.
    /// </summary>
    internal class OperationFailedEventArgs : EventArgs
    {
        #region Retry Property

        private bool shouldRetry;

        /// <summary>
        /// Gets or sets a value indicating whether the operation should be retried.
        /// </summary>
        public bool ShouldRetry
        {
            get
            {
                return this.shouldRetry;
            }
            set
            {
                this.shouldRetry = value;
            }
        }

        #endregion

        #region RetryCount Property

        private readonly int retryCount;

        /// <summary>
        /// Gets the number of retries that have already taken place before this event.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public int RetryCount
        {
            get
            {
                return this.retryCount;
            }
        }

        #endregion

        #region Exception Property

        private readonly Exception exception;

        /// <summary>
        /// Gets the exception that caused the operation to fail.
        /// </summary>
        public Exception Exception
        {
            get
            {
                return this.exception;
            }
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="OperationFailedEventArgs"/> class.
        /// </summary>
        /// <param name="exception">The exception that caused the operation to fail.</param>
        /// <param name="shouldRetry">A value indicating whether the event should be retried.</param>
        /// <param name="retryCount">The number of retries that have already taken place before this event.</param>
        public OperationFailedEventArgs(Exception exception, bool shouldRetry, int retryCount)
        {
            this.exception = exception;
            this.shouldRetry = shouldRetry;
            this.retryCount = retryCount;
        }

        #endregion
    }
}